package demo;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import java.util.ArrayList;
import java.util.List;

public class RecognitionToolTest {

    @Test
    void testRecognizeShoppingList() {
        List<Layer> openLayers = new ArrayList<>();
        List<Layer> closeLayers = new ArrayList<>();
        List<Goods> goodsList = new ArrayList<>();
        List<Stock> stockList = new ArrayList<>();

        // 添加虚拟数据
        openLayers.add(new Layer(1, 1000));
        openLayers.add(new Layer(2, 2000));

        closeLayers.add(new Layer(1, 900));
        closeLayers.add(new Layer(2, 1800));

        goodsList.add(new Goods("A001", 100));
        goodsList.add(new Goods("B001", 200));

        stockList.add(new Stock("A001", 1, 5));
        stockList.add(new Stock("B001", 2, 3));

        // 测试识别算法
        RecognitionTool recognitionTool = new RecognitionTool(1,2);
        RecognitionResult result = recognitionTool.recognize(openLayers, closeLayers, goodsList, stockList);

        // 输出识别结果
        System.out.println("Recognition Successful: " + result.isSuccessful());
        System.out.println("Shopping List: ");
        for (RecognitionItem item : result.getItems()) {
            System.out.println(item.getGoodsId() + " - Quantity: " + item.getNum());
        }
        System.out.println("Exceptions: ");
        for (RecognitionException exception : result.getExceptions()) {
            System.out.println("Layer: " + exception.getLayer() + " - Exception: " + exception.getException());
        }
    }


}
